fo = open("PY202.txt","w")
names = input("请输入各个同学职业名称，职业名称之间用空格间隔（按<Enter>键结束输入：\n")
names_list = names.split(' ') 
d = {}
for item in names_list:
    d[item] =  d.get(item,0)+1
ls = list(d.items())
ls.sort(key = lambda x: x[1],reverse = True)
for k in ls:
    fo.write("{}:{}".format(k[0],k[1]))
fo.close()
